package com.leejxx.kafka.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author LeeJx
 * @ClassName HelloController
 * @Description TODO
 * @date 2021/2/27 12:18
 * @Version 1.0
 */
@RestController
public class HelloController {
    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    @GetMapping("/hello")
    public String hello(){
        //第一个参数：topics
        //第二个参数：消息内容
        kafkaTemplate.send("kafka-hello","你好，kafka");
        return "ok";
    }
}
